package org.msb.accentis.gui.managedialog;

import javax.swing.JComponent;

import org.msb.accentis.data.pojo.NamedObject;

public abstract class AbstractManageDialogPage<T extends NamedObject> {

	private ManagePojoDialog managePojoDialog;
	
	protected AbstractManageDialogPage(ManagePojoDialog dialog) {
		managePojoDialog = dialog;
	}
	
	abstract JComponent getComponent();
	
	protected abstract void doFinish();
	
	protected abstract void setCurrentPojo(T object);
	
	protected ManagePojoDialog getManagePojoDialog() {
		return managePojoDialog;
	}
	
	boolean canFinish() {
		return false;
	}
	
	String getTitleParameter() {
		return null;
	}
	
	public void createPojo() {
		show(null);
	}
	
	public void editPojo(T object) {
		show(object);
	}
	
	private void show(T object) {
		getManagePojoDialog().setPage(this);
		setCurrentPojo(object);
		getManagePojoDialog().setVisible(true);
	}
}
